<template>
  <div class="home-page">
    <div class="home-page-capsule h-200rpx " :style="{ height: capsuleHeight + 'px', top: capsuleTop + 'px' }">
      <!-- 你的胶囊按钮内容 -->
      {{ Address.contactAddress }}
    </div>
    <div class="home-page-banner">
      <image :src="banner" mode="aspectFill" lazy-load></image>
    </div>
    <div class="home-page-content">
      <!-- 第一个搜索框 -->
      <div class="search-input" ref="searchInputRef">
        <div class="search-input-wrapper">
          <div class="search-input-prefix">
            <img src="../static/imgs/Merchant/sousuo2.png" alt="搜索" class="search-icon">
          </div>
          <input v-model="searchValue" type="text" placeholder="搜索商家或商品" class="search-input-native"
            @input="handleChange" @blur="handleSearchBlur" />
          <div class="search-input-suffix" @click.stop="handleSearch">
            搜索
          </div>
        </div>
      </div>
      <div class="home-page-content-header">
        <!-- 分类 -->
        <div class="header-top-Classification">
          <template v-for="item in classificationList" :key="item">
            <div :class="{ 'Class-active': activeClassificationId == item.shopCategoryId }"
              class="header-top-Classification-item" @click="handleClassification(item)">
              <div class="header-top-Classification-item-icon">
                <image :src="item.shopCategoryIcon" mode="aspectFill" lazy-load></image>
              </div>
              <div class="header-top-Classification-item-title">
                {{ item.shopCategoryName }}
              </div>
            </div>
          </template>
        </div>
        <!-- 热门美食 -->
        <div class="header-top-hot">
          <div class="header-top-hot-title">
            <span>热门美食</span>
            <!-- <span class="header-top-hot-more">更多></span> -->
          </div>
          <div class="header-top-hot-content">
            <template v-for="(item, index) in hotGoodsList" :key="item">
              <div @click="handleHotGoods(item)" class="header-top-hot-content-item" v-if="index < 4">
                <image :src="item.thumbnail || '../static/imgs/caipinmoren.png'" mode="aspectFill" lazy-load></image>
                <div class="header-top-hot-content-item-title">
                  {{ item.goodsName }}
                </div>
                <div class="header-top-hot-content-item-button">
                  <div>￥{{ item.listGoodsSkus?.[0]?.priceStr || item.listGoodsSkus?.[0]?.marketPrice || 0 }}</div>
                  <div class="button-icon">+</div>
                </div>
              </div>
            </template>
          </div>
        </div>
        <!-- 校园商家 -->
        <div class="header-top-campus-business">
          <div class="header-top-campus-business-title">
            <span>校园商家</span>
          </div>
          <div class="header-top-campus-business-content">
            <template v-for="item in shopList" :key="item.id">
              <div @click="handleMerchant(item)" class="header-top-campus-business-content-item"
                :class="{ 'business-closed': item.businessStatus === 0 }">
                <div class="business-content-item-header">
                  <image :src="item.logo || '/static/imgs/dianpumoren.png'" mode="aspectFill" lazy-load></image>
                  <div class="business-content-item-header-title">
                    <div class="business-content-item-header-title-top">
                      <span class="store-name">{{ item.shopName }}</span>
                      <span class="store-name-tag">{{ ConversionShopType(item.shopTypeId) }}</span>
                      <!-- 添加营业状态标识 -->
                      <span class="business-status" :class="{ 'status-closed': item.businessStatus === 0 }">
                        {{ item.businessStatus === 1 ? '营业中' : '休息中' }}
                      </span>
                    </div>
                    <div class="business-content-item-header-title-button">
                      <!-- <span>月销200+</span> -->
                      <span>配送费¥{{ item.deliveryFeeStr || 0 }}</span>
                      <span>起送¥{{ item.startFeeStr || 0 }}</span>
                    </div>
                  </div>
                </div>
                <div class="business-content-item-content">
                  <template v-if="item.listGoodsInfo?.length > 0">
                    <template v-for="itm in item.listGoodsInfo" :key="item">
                      <div class="business-content-item-content-item">
                        <image :src="itm.thumbnail || '../static/imgs/caipinmoren.png'" mode="aspectFill" lazy-load></image>
                        <div class="business-content-item-content-item-title">
                          <span class="title">{{ itm.goodsName }}</span>
                          <span class="priceStr">￥{{ itm.listGoodsSkus?.[0]?.priceStr ||
                            itm.listGoodsSkus?.[0]?.marketPrice
                            ||
                            0 }}</span>
                        </div>
                      </div>
                    </template>
                  </template>
                  <template v-else>
                    <div class="business-content-item-content-item-wu">
                      <image src="../static/imgs/zanwu.png" mode="aspectFill" lazy-load></image>
                      <div class="text">暂无商品</div>
                    </div>
                  </template>
                </div>
              </div>
            </template>
          </div>
        </div>
      </div>
    </div>
    <!-- 底部导航 -->
    <bottomNav />
    <!-- 固定的搜索框 -->
    <div class="search-input-fixed" :class="{ 'search-input-fixed-show': isSearchFixed }"
      :style="searchInputFixedStyle">
      <div class="search-input">
        <div class="search-input-wrapper">
          <div class="search-input-prefix">
            <img src="../static/imgs/Merchant/sousuo2.png" alt="搜索" class="search-icon">
          </div>
          <input v-model="searchValue" type="text" placeholder="搜索商家或商品" class="search-input-native"
            @input="handleChange" />
          <div class="search-input-suffix">
            搜索
          </div>
        </div>
      </div>
    </div>

  </div>
</template>

<script setup>
import { ref, onMounted, computed } from 'vue'
import { useBottomNavStore } from '@/stores/bottomNav'
const bottomNavStore = useBottomNavStore()
import { baseUrl } from '@/utils/config'
import bottomNav from '@/components/bottomNav.vue'
import { useLoginStore } from '@/stores/login.js'
import { loginWithCode } from '@/utils/wechat.js'
import { useUserStore } from '@/stores/user.js'

const capsuleHeight = ref(0)
const capsuleTop = ref(0)
const isSearchFixed = ref(false)
const searchValue = ref('')
const scrollTop = ref(0)
const searchInputRef = ref(null)

const classificationList = ref([])
const selectedCategoryId = ref('')

// 添加防抖函数
let getListTimer = null
let onReachBottomTimer = null

const debouncedGetList = (categoryId, isRefresh = false) => {
  if (getListTimer) {
    clearTimeout(getListTimer)
  }
  getListTimer = setTimeout(() => {
    getList(categoryId, isRefresh)
  }, 300) // 300ms 防抖延迟
}

const isTest = computed(() => {
  return baseUrl.includes('http://119.91.216.71:8088')
})

const shopTotal = ref(0)

// 修改获取店铺列表的方法 - 修复版本
const getList = async (categoryId, isRefresh = false) => {
  if (loading.value) return

  // 如果是刷新，重置分页状态
  if (isRefresh) {
    currentPage.value = 1
    noMoreData.value = false
    shopList.value = []
    console.log('刷新模式，重置页码为1', searchValue.value)
  } else {
    // 非刷新模式，页码应该在上拉时已经递增
    console.log('非刷新模式，当前页码:', currentPage.value)
  }

  loading.value = true
  console.log('开始请求，页码:', currentPage.value, '是否刷新:', isRefresh);

  try {
    const res = await Fetch('shopping/shopInfo/homeList', {
      method: 'get',
      data: {
        pageNum: currentPage.value,
        pageSize: pageSize.value,
        shopName: searchValue.value != undefined ? searchValue.value : '',
        isShelves: 1,
        shopTypeId: categoryId ? categoryId : ''
      },
    })

    console.log(res.data, 'res.data.msg123123213', res.status);
    if (res.status === 200) {
      const newData = res.data.rows || []
      shopTotal.value = res.data.total
      console.log('请求成功，返回数据:', newData.length, '条', '总数据量:', shopTotal.value);

      if (isRefresh) {
        shopList.value = newData
        console.log('刷新模式，替换数据')
      } else {
        shopList.value = [...shopList.value, ...newData]
        console.log('追加模式，当前总数据:', shopList.value.length, '条')
      }

      // 修改判断逻辑：检查当前已加载的数据量是否大于等于总数据量
      if (shopList.value.length >= shopTotal.value) {
        noMoreData.value = true
        console.log('没有更多数据了，已加载:', shopList.value.length, '总数据:', shopTotal.value)
      } else if (newData.length === 0 || newData.length < pageSize.value) {
        noMoreData.value = false
      }

      if (res.data.code === 500) {
        uni.showModal({
          title: '温馨提示',
          content: res.data.msg,
          showCancel: false,
          success: (res) => {
            if (res.confirm) {
              uni.reLaunch({
                url: '/pages/ClosingTime',
              })
            }
          }
        })
      }
    } else {
      uni.showModal({
        title: '温馨提示',
        content: res.data.msg,
        success: (res) => {
          if (res.confirm) {
            if (res.data.msg.includes('平台已经打烊啦')) {

            }
          }
        }
      })
    }
  } catch (error) {
    console.error('获取店铺列表失败:', error)
    uni.showToast({
      title: '加载失败，请重试',
      icon: 'none'
    })
  } finally {
    loading.value = false
  }
}



// 或者更安全的做法，添加一个标志位
let isUserTyping = false

const handleChange = (val) => {
  console.log(val, 'val');
  isUserTyping = true

  // 清除之前的定时器
  if (getListTimer) {
    clearTimeout(getListTimer)
  }

  getListTimer = setTimeout(() => {
    // 只有当用户真正输入时才执行搜索
    if (isUserTyping) {
      searchValue.value = val.detail.value
      shopList.value = []
      activeClassificationId.value = null
      currentPage.value = 1
      debouncedGetList(activeClassificationId.value, true)
      isUserTyping = false
    }
  }, 500) // 增加延迟到500ms
}

// 在搜索框失去焦点时重置标志位
const handleSearchBlur = () => {
  isUserTyping = false
}

// const handleSearch = () => {
//   getList()
// }

// 使用节流函数来优化性能
let scrollTimer = null
const handleScroll = (e) => {
  if (scrollTimer) {
    clearTimeout(scrollTimer)
  }

  scrollTimer = setTimeout(() => {
    const scrollTop = e.detail.scrollTop

    // #ifdef MP-WEIXIN
    const query = uni.createSelectorQuery()
    query.select('.search-input').boundingClientRect((rect) => {
      if (rect) {
        // 当搜索框顶部位置小于等于胶囊按钮底部位置时，显示固定搜索框
        isSearchFixed.value = rect.top <= (capsuleTop.value + capsuleHeight.value)
      }
    }).exec()
    // #endif
  }, 16) // 约60fps的刷新率
}

const searchInputFixedStyle = computed(() => {
  return {
    height: `${capsuleTop.value + capsuleHeight.value + 60}px`
  }
})
// 校园商家点击
const handleMerchant = (shop) => {
  // 如果店铺停业，显示提示信息，不允许进入
  if (shop.businessStatus === 0) {
    uni.showToast({
      title: '店铺暂停营业',
      icon: 'none',
      duration: 2000
    })
    return
  }

  // 营业中的店铺可以正常进入
  uni.navigateTo({
    url: `/pages/Merchant?shopId=${shop.shopId}`,
  })
}
onMounted(() => {
  // #ifdef MP-WEIXIN
  const menuButtonInfo = wx.getMenuButtonBoundingClientRect()
  capsuleHeight.value = menuButtonInfo.height
  capsuleTop.value = menuButtonInfo.top
  console.log('胶囊按钮信息:', menuButtonInfo)
  // #endif
})

const loginStore = useLoginStore()



const userStore = useUserStore()

const getMyShopList = async () => {
  await userStore.getMyShopInfo()
}

// 店铺列表相关变量
const shopList = ref([])
const currentPage = ref(1)
const pageSize = ref(3)
const loading = ref(false)
const noMoreData = ref(false)
const totalPages = ref(0)

// 修改搜索方法，使用防抖
const handleSearch = () => {
  shopList.value = []
  currentPage.value = 1
  activeClassificationId.value = null
  debouncedGetList(activeClassificationId.value, true) // 使用防抖版本
}

// 添加活跃分类ID变量
const activeClassificationId = ref('')

// 获取店铺分类列表
const getShopClassList = async () => {
  const res = await Fetch('shopping/ShopCategory/list', {
    method: 'get',
  })
  if (res.data.code === 200) {
    const list = res.data.rows
    classificationList.value = list
  } else if (res.data.code === 10001) {

  } else {
    uni.showToast({
      title: res.data.msg,
      icon: 'none'
    })
  }
}

// 分类点击 - 修复版本
const handleClassification = (item) => {
  // 如果当前点击的分类已经是激活的分类，清除activeClassificationId
  if (activeClassificationId.value === item.shopCategoryId) {
    activeClassificationId.value = null;  // 清空激活分类
    debouncedGetList(null, true);  // 使用防抖版本，加载所有数据
  } else {
    activeClassificationId.value = item.shopCategoryId;  // 更新为新选中的分类
    debouncedGetList(item.shopCategoryId, true);  // 使用防抖版本，加载指定分类
  }
}

const ConversionShopType = (type) => {
  return classificationList.value.find(item => item.shopCategoryId === type)?.shopCategoryName || '无'
}

const hotGoodsList = ref([])
const getHotGoods = async () => {
  const res = await Fetch('shopping/goodsInfo/hotList', {
    method: 'get',
    data: {
      page: 1,
      pageSize: 10,
      isShelves: 1
    }
  })
  if (res.data.code === 200) {
    hotGoodsList.value = res.data.rows
  }
}

onShareAppMessage(() => {
  return {
    title: '快跑吖-校园外卖平台',
    path: '/pages/index',
    imageUrl: '/static/imgs/logo.jpg',
  }
})

// 热门美食点击
const handleHotGoods = (item) => {
  uni.navigateTo({
    url: `/pages/Merchant?shopId=${item.shopId}&categoryId=${item.categoryId}&goodsId=${item.goodsId}`,
  })
}

// 获取用户地址数据拿默认地址
const Address = ref({})
const loadAddressList = async () => {
  try {
    const { status, data } = await Fetch(`shopping/address/list`, { method: 'get' })
    console.log(status, data);

    if (status === 200 && data.code === 200) {
      data.rows.forEach(item => {
        if (item.defaultAddress == 1) {
          Address.value = item
        }
      })
    }
  } catch (error) {
    uni.showToast({
      title: '加载失败',
      icon: 'error'
    })
  } finally {
  }
}
onLoad(async (option) => {
  await loadAddressList()
  await getMyShopList()
  await getList('', true) // 初始加载时刷新列表
  await getHotGoods()
  await getUserInfo()
  await getBanner()
  await getShopClassList()

})

onShow(async () => {
  bottomNavStore.setActiveIndex(0)
})

// 添加获取用户信息的方法
const getUserInfo = async () => {
  try {
    // 调用store中的方法更新用户信息
    await userStore.updateUserInfo()
    console.log('用户信息更新成功:', userStore.customerInfo)
  } catch (error) {
    console.error('获取用户信息失败:', error)
  }
}



// 上拉加载更多 - 不需要防抖，直接调用

const banner = ref('')
// 获取首页banner
const getBanner = async () => {
  const { data } = await Fetch('shopping/dict/data/type/imag_list', { method: 'get' })
  if (data.code === 200) {

    data.data.map(item => {
      if (item.dictLabel == '首页banner') {
        banner.value = item.dictValue
      }
    })
  }
}

// 页面滚动监听
onPageScroll((e) => {
  const scrollTop = e.scrollTop
  const query = uni.createSelectorQuery()
  query.select('.search-input').boundingClientRect((rect) => {
    if (rect) {
      // 当搜索框顶部位置小于等于胶囊按钮底部位置时，显示固定搜索框
      isSearchFixed.value = rect.top <= (capsuleTop.value + capsuleHeight.value)
    }
  }).exec()
})

// 修改 onReachBottom 函数，添加页码递增逻辑
onReachBottom(() => {
  console.log('上拉加载更多')
  // 检查是否正在加载或没有更多数据
  if (loading.value || noMoreData.value) {
    uni.showToast({
      title: '没有更多数据了',
      icon: 'none'
    })
    console.log('正在加载中或没有更多数据，跳过')
    return
  }
  // 递增页码
  currentPage.value++
  console.log('页码递增到:', currentPage.value)

  getList(activeClassificationId.value, false)
})
</script>

<style lang="scss" scoped>
.home-page {
  height: 100%;

  .home-page-capsule {
    width: 100%;
    position: fixed;
    left: 20rpx;
    display: flex;
    align-items: center;
    text-align: left;
    z-index: 102;
  }

  .home-page-banner {
    width: 750rpx;
    height: 500rpx;
    position: relative;

    image {
      width: 100%;
      height: 100%;
    }
  }

  .home-page-content {
    margin-top: -120rpx;

    position: relative;


    .home-page-content-header {
      width: 750rpx;
      background: #F7F7F8;
      border-radius: 60rpx 60rpx 0rpx 0rpx;

      .header-top-Classification {
        display: flex;
        align-items: center;
        margin-top: 30rpx;
        flex-wrap: wrap;
        padding: 50rpx 30rpx 0;

        .header-top-Classification-item {
          width: 20%;
          display: flex;
          flex-direction: column;
          align-items: center;
          margin-bottom: 30rpx;
          padding: 10rpx 0;

          .header-top-Classification-item-icon {
            width: 88rpx;
            height: 88rpx;
            border-radius: 50%;
            margin-bottom: 10rpx;

            image {
              width: 100%;
              height: 100%;
            }
          }

          .header-top-Classification-item-title {
            font-size: 24rpx;
            color: #191919;
          }
        }

      }

      .header-top-hot {
        width: 710rpx;
        height: 382rpx;
        margin: 0 auto;
        background: #FFFFFF;
        border-radius: 20rpx 20rpx 20rpx 20rpx;
        padding: 20rpx 24rpx;
        box-sizing: border-box;

        .header-top-hot-title {
          font-size: 34rpx;
          color: #000000;
          font-weight: bold;
          display: flex;
          align-items: center;

          .header-top-hot-more {
            font-size: 24rpx;
            color: #9B9B9B;
            font-weight: normal;
            margin-left: auto;
          }
        }

        .header-top-hot-content {
          display: flex;
          align-items: center;
          gap: 14rpx;
          flex-wrap: wrap;
          margin-top: 20rpx;

          .header-top-hot-content-item {
            width: 154rpx;

            image {
              width: 154rpx;
              height: 154rpx;
              border-radius: 10rpx 10rpx 10rpx 10rpx;
              margin-bottom: 5rpx;
            }

            .header-top-hot-content-item-title {
              font-size: 24rpx;
              color: #191919;
              font-weight: normal;
              height: 1.4em;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap; // 单行显示，超出部分显示省略号
            }

            .header-top-hot-content-item-button {
              width: 154rpx;
              height: 42rpx;
              background: #F9EBE8;
              border-radius: 22rpx 22rpx 22rpx 22rpx;
              display: flex;
              align-items: center;
              padding-left: 16rpx;
              margin-top: 10rpx;
              box-sizing: border-box;

              view {
                font-weight: bold;
                color: #EB4A5F;
                font-size: 28rpx;
              }

              .button-icon {
                width: 52rpx;
                height: 42rpx;
                text-align: center;
                line-height: 38rpx;
                display: inline;
                font-size: 32rpx;
                color: white;
                margin-left: auto;
                background: linear-gradient(180deg, #EC6C59 0%, #EB4760 100%);
                border-radius: 22rpx 22rpx 22rpx 22rpx;
                opacity: 0.7;
              }
            }
          }
        }
      }

      .header-top-campus-business {
        margin-top: 30rpx;
        background: #F7F7F8;

        .header-top-campus-business-title {
          font-size: 34rpx;
          color: #000000;
          font-weight: bold;
          width: 750rpx;
          background: url('../static/imgs/xysj-bj.png') no-repeat center center;
          background-size: 100% 100%;
          padding: 24rpx 0 0 44rpx;
          box-sizing: border-box;

          label {
            position: relative;

            &::after {
              content: '';
              display: block;
              width: 30rpx;
              height: 8rpx;
              background: #F9E052;
              border-radius: 4rpx 4rpx 4rpx 4rpx;
              position: absolute;
              bottom: -15rpx;
              left: 50%;
              transform: translateX(-50%);
            }
          }
        }

        .header-top-campus-business-content {
          margin-top: 30rpx;
          padding-bottom: 120rpx;

          .header-top-campus-business-content-item {
            width: 710rpx;
            background: #FFFFFF;
            margin: 0 auto 20rpx;
            border-radius: 20rpx 20rpx 20rpx 20rpx;
            padding: 18rpx 0 24rpx 24rpx;
            box-shadow: 0 2px 8px rgba(123, 123, 122, 0.15);
            box-sizing: border-box;

            .business-content-item-header {
              display: flex;
              align-items: center;

              image {
                width: 88rpx;
                height: 88rpx;
                border-radius: 16rpx 16rpx 16rpx 16rpx;
                margin-right: 16rpx;
              }

              .business-content-item-header-title {
                padding-right: 20rpx;
                flex: 1;

                .business-content-item-header-title-top {
                  display: flex;
                  align-items: center;

                  .store-name {
                    font-size: 30rpx;
                    color: #000000;
                    font-weight: bold;
                  }

                  .store-name-tag {
                    background: #FFFFFF;
                    border-radius: 10rpx 10rpx 10rpx 10rpx;
                    border: 1rpx solid #F9D9B7;
                    padding: 4rpx 8rpx 2rpx;
                    box-sizing: border-box;
                    font-size: 16rpx;
                    color: #EF8633;
                    height: 28rpx;
                    line-height: 20rpx;
                    margin-left: auto;
                    margin-right: 22rpx;
                  }
                }

                .business-content-item-header-title-button {
                  display: flex;
                  color: #A0A0A0;
                  font-size: 22rpx;
                  margin-top: 10rpx;

                  label {
                    display: block;
                    font-size: 24rpx;
                    color: #9B9B9B;
                    font-weight: normal;
                    margin-right: 24rpx;
                  }
                }
              }

            }

            .business-content-item-content {
              display: flex;
              align-items: center;
              margin-top: 30rpx;
              overflow-x: auto;

              .business-content-item-content-item {
                width: 132rpx;
                margin-right: 20rpx;

                image {
                  width: 132rpx;
                  height: 132rpx;
                  border-radius: 10rpx 10rpx 10rpx 10rpx;
                }

                label {
                  display: block;
                }

                .title {
                  width: 132rpx;
                  font-size: 22rpx;
                  color: #212121;
                  font-weight: normal;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                }

                .priceStr {
                  font-weight: bold;
                  font-size: 28rpx;
                  color: #EA5A41;
                  line-height: 40rpx;
                  text-align: left;
                  font-style: normal;
                  text-transform: none;
                }
              }

            }
          }
        }
      }
    }
  }

  .search-input {
    width: 80%;
    margin: 0 auto;
    border-radius: 40px;
    padding: 0 10px;

    .search-input-wrapper {
      display: flex;
      align-items: center;
      background: #fff;
      border-radius: 50rpx;
      padding: 8rpx 20rpx;
      box-sizing: border-box;
      box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.06);
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      border: 2rpx solid rgba(0, 0, 0, 0.06);

      &:hover {
        box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.08);
      }

      &:focus-within {
        box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.1);
        border-color: rgba(0, 0, 0, 0.1);
      }

      .search-input-prefix {
        width: 40rpx;
        height: 40rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 16rpx;
        background: #999;
        border-radius: 50%;
        backdrop-filter: blur(10rpx);

        .search-icon {
          width: 32rpx;
          height: 32rpx;
          filter: brightness(0) saturate(100%) invert(100%);
        }
      }

      .search-input-native {
        flex: 1;
        height: 40rpx;
        font-size: 28rpx;
        color: #222425;
        padding: 0;
        border: none;
        outline: none;
        background: transparent;
        font-weight: 500;

        &::placeholder {
          color: rgba(34, 36, 37, 0.7);
          font-weight: 400;
        }
      }

      .search-input-suffix {
        width: 92rpx;
        height: 52rpx;
        background: #999;
        font-size: 26rpx;
        color: #fff;
        font-weight: 600;
        border-radius: 26rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: 16rpx;
        box-shadow: 0 4rpx 16rpx rgba(34, 36, 37, 0.3);
        transition: all 0.2s ease;
        cursor: pointer;

        &:active {
          transform: scale(0.95);
          box-shadow: 0 2rpx 8rpx rgba(34, 36, 37, 0.4);
        }
      }
    }
  }

  .search-input-fixed {
    position: fixed;
    top: -400rpx;
    left: 0;
    width: 100vw;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20rpx);
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-30px);
    transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
    border-radius: 0 0 24px 24px;
    padding-bottom: 20rpx;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 9;

    .search-input {
      width: 80%;
      margin: 0 auto;
      border-radius: 40px;
      padding: 0 10px;

      .search-input-wrapper {
        display: flex;
        align-items: center;
        background: #fff;
        border-radius: 50rpx;
        padding: 8rpx 20rpx;
        box-sizing: border-box;
        box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.06);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border: 2rpx solid rgba(0, 0, 0, 0.06);

        &:hover {
          box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.08);
        }

        &:focus-within {
          box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.1);
          border-color: rgba(0, 0, 0, 0.1);
        }

        .search-input-prefix {
          width: 40rpx;
          height: 40rpx;
          display: flex;
          align-items: center;
          justify-content: center;
          margin-right: 16rpx;
          background: #999;
          border-radius: 50%;
          backdrop-filter: blur(10rpx);

          .search-icon {
            width: 32rpx;
            height: 32rpx;
            filter: brightness(0) saturate(100%) invert(100%);
          }
        }

        .search-input-native {
          flex: 1;
          height: 40rpx;
          font-size: 28rpx;
          color: #222425;
          padding: 0;
          border: none;
          outline: none;
          background: transparent;
          font-weight: 500;

          &::placeholder {
            color: rgba(34, 36, 37, 0.7);
            font-weight: 400;
          }
        }

        .search-input-suffix {
          width: 92rpx;
          height: 52rpx;
          background: #999;
          font-size: 26rpx;
          color: #fff;
          font-weight: 600;
          border-radius: 26rpx;
          display: flex;
          align-items: center;
          justify-content: center;
          margin-left: 16rpx;
          box-shadow: 0 4rpx 16rpx rgba(34, 36, 37, 0.3);
          transition: all 0.2s ease;
          cursor: pointer;

          &:active {
            transform: scale(0.95);
            box-shadow: 0 2rpx 8rpx rgba(34, 36, 37, 0.4);
          }
        }
      }
    }
  }

  .search-input-fixed-show {
    top: 0px;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(123, 123, 122, 0.15);
  }

  .search-input-fixed :deep(.wd-input) {
    background: #f7f7fa;
    border-radius: 32px;
    box-shadow: 0 2px 8px rgba(249, 222, 74, 0.08);
    border: 1.5px solid #f9de4a;
    padding: 0 12px;
    font-size: 16px;
  }

  .search-input-fixed :deep(.wd-input .wd-input__input) {
    background: transparent;
    font-size: 16px;
    color: #222425;
    font-weight: 500;
  }

  .search-input-fixed .search-input-suffix {
    width: 72px;
    height: 36px;
    background: linear-gradient(90deg, #f9de4a 0%, #f7b52a 100%);
    font-size: 16px;
    color: #222425;
    font-weight: bold;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(249, 222, 74, 0.15);
    margin-left: 8px;
    cursor: pointer;
    transition: background 0.2s;
  }

  .search-input-fixed .search-input-suffix:active {
    background: linear-gradient(90deg, #f7b52a 0%, #f9de4a 100%);
  }

  :deep(.wd-input) {
    border-radius: 40rpx;
    padding: 0 10rpx;

    &::after {
      background: transparent;
    }
  }

  .business-content-item-content-item-wu {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 0 auto;
    text-align: center;

    image {
      width: 281rpx;
      height: 213rpx;
    }

    .text {
      margin-top: 10px;
      font-size: 24rpx;
    }
  }

  // 添加营业状态的样式
  .business-status {
    font-size: 20rpx;
    padding: 6rpx 12rpx;
    border-radius: 12rpx;
    font-weight: 500;
    margin-left: 16rpx;

    // 营业中状态
    &:not(.status-closed) {
      background: linear-gradient(135deg, #52c41a, #73d13d);
      color: #fff;
      box-shadow: 0 2rpx 8rpx rgba(82, 196, 26, 0.3);
    }

    // 停业状态
    &.status-closed {
      background: linear-gradient(135deg, #ff4d4f, #ff7875);
      color: #fff;
      box-shadow: 0 2rpx 8rpx rgba(255, 77, 79, 0.3);
    }
  }

  // 保持原有的 store-name-tag 样式不变
  .store-name-tag {
    background: #FFFFFF;
    border-radius: 10rpx 10rpx 10rpx 10rpx;
    border: 1rpx solid #F9D9B7;
    padding: 4rpx 8rpx 2rpx;
    box-sizing: border-box;
    font-size: 16rpx;
    color: #EF8633;
    height: 28rpx;
    line-height: 20rpx;
    margin-left: auto;
    margin-right: 22rpx;
  }
}

:deep(.wd-input::after) {
  background-color: transparent !important
}

.load-more-tip {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40rpx 0;
  font-size: 28rpx;
  color: #999;

  .loading {
    display: flex;
    align-items: center;
    gap: 20rpx;
  }

  .no-more {
    color: #ccc;
  }

  .pull-up {
    color: #666;
  }
}

.Class-active {
  box-shadow: 1px 1px 1px 5px #e9e9e9;
  border-radius: 10px;
}
</style>
